#include <iostream>
#include <string>
#include <vector>

void wordSelect(std::vector<std::string> &select_words,
                std::vector<std::string> &words,
                std::vector<int> &used)
{
    int idx = -1;
    std::string curr = "";
    for (int i = 0; i < words.size(); i++)
    {
        if (used[i] == 0)
        {
            std::string ww = select_words.back();
            if (ww.back() == words[i][0])
            {
                if (curr.size() < words[i].size() || curr > words[i])
                {
                    curr = words[i];
                    idx = i;
                    // std::cout << curr << " " << i << std::endl;
                }
            }
        }
    }

    if (idx == -1)
    {
        return;
    }
    else
    {
        select_words.push_back(curr);
        used[idx] = 1;
        wordSelect(select_words,
                   words,
                   used);
    }
}

int main()
{
    int k, N;
    std::cin >> k;
    std::cin >> N;

    std::vector<std::string> words;
    for (int i = 0; i < N; i++)
    {
        std::string word;
        std::cin >> word;
        words.push_back(word);
    }

    std::vector<int> used(N, 0);
    std::vector<std::string> selected_words;
    selected_words.push_back(words[k]);
    used[k] = 1;

    wordSelect(selected_words, words, used);
    for (int i = 0; i < selected_words.size(); i++)
    {
        std::cout << selected_words[i];
    }

    return 0;
}